﻿using AutoMapper.Internal.Mappers;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using ThreeObject.ERP.DTO;
using ThreeObject.ERP.Model.Wang;
using ThreeObject.ERP.Wang;

namespace ThreeObject.ERP.Web.Controllers.Wang
{
    /// <summary>
    /// 职级管理控制器
    /// </summary>
    public class PositionManagementController : Controller
    {
        /// <summary>
        /// 职级管理接口
        /// </summary>
        private readonly IPositionManagementServices _IPositionManagementServices;
        /// <summary>
        /// 直接管理构造方法
        /// </summary>
        /// <param name="iPositionManagementServices"></param>
        public PositionManagementController(IPositionManagementServices iPositionManagementServices)
        {
            _IPositionManagementServices = iPositionManagementServices;
        }

        public IActionResult Index()
        {
            return View();
        }
        [HttpPost]
        /// <summary>
        /// 添加职位管理
        /// </summary>
        /// <param name="jobGradeManagementModel"></param>
        /// <returns></returns>
        public async Task<JobGradeManagementModel> AddJobGradeManagementModel([FromBody]JobGradeManagementModelDTO jobGradeManagementModel)
        {
            return await _IPositionManagementServices.AddJobGradeManagementModel(jobGradeManagementModel);
        }

        /// <summary>
        /// 职位等级视图
        /// </summary>
        /// <returns></returns>
        public IActionResult JobGradeManagement()
        {
            return View();
        }         
        [HttpGet]
        /// <summary>
        /// 显示职位信息
        /// </summary>
        /// <returns></returns>
     
        [HttpGet]
        public async Task<IActionResult> GetJobGradeTableData([FromQuery] QueryJobGradeManagementDTO queryJobGradeManagementDTO)
        {
            var list = await _IPositionManagementServices.QueryJobGradeManagement(queryJobGradeManagementDTO);
            return Json(new
            {
                code = 0,
                msg = "",
                count = list.Count, // 如果有分页，这里应为总条数
                data = list
            });
        }


    }
}
